package com.viewpagerindicator.sample;

import android.app.Application;
import android.bluetooth.BluetoothDevice;

import com.viewpagerindicator.sample.util.ACache;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhao on 2015/11/10.
 */
public class CutokApplication extends Application {
    public BluetoothDevice lastBluetoothDevice=null;
    public List<BluetoothDevice> deviceList=new ArrayList<>();
    ACache mCache ;
    public static String SESSION_ID=null;
    public static String USER_LOGIN_NAME=null;
    @Override
    public void onCreate() {
        // TODO Auto-generated method stub
        super.onCreate();
        mCache=ACache.get(this);
        SESSION_ID=mCache.getAsString("SESSION_ID");
        USER_LOGIN_NAME=mCache.getAsString("USER_LOGIN_NAME");
    }
    public boolean isLogined(){
        if(SESSION_ID==null){
            return false;
        }else{
            return true;
        }
    }
    public void loginSuccess(String sessionId,String userLoginName){
        SESSION_ID=sessionId;
        USER_LOGIN_NAME=userLoginName;
        mCache.put("SESSION_ID",SESSION_ID);
        mCache.put("USER_LOGIN_NAME",USER_LOGIN_NAME);
    }
    public void logout(){
        SESSION_ID=null;
        mCache.remove("SESSION_ID");
        mCache.remove("USER_LOGIN_NAME");
    }
    public String getSessionId(){
        return SESSION_ID;
    }
    public String getUserLoginName(){
        return USER_LOGIN_NAME;
    }
}
